<?
include("common/header.html");
include("common/left.html");
include("common/page.php");
//-------------------------------------------------------
$showOfflineFlag = false;
$accountLimitList = array(123950,123951,123952,123953,123954,123955,3348);//云顶供应商账号
$accountLimitList[] = 100014;//测试账号
$accountLimitList[] = 200566;//测试账号
$host = $_SERVER['HTTP_HOST'];
if($_SERVER['HTTP_HOST']=='yyd.12301.cc' || in_array( $_SESSION['saccount'],$accountLimitList)) {
    $showOfflineFlag = true;
}

$sql = "select etime from uu_bill where fid={$_SESSION['sid']} order by id desc limit 1";
$GLOBALS['le']->query($sql);
$GLOBALS['le']->fetch_assoc();
$etime = $GLOBALS['le']->f('etime');
$moon = date('m',$_SERVER['REQUEST_TIME'])-1;
$memberID=$_SESSION['sid'];
if($etime<date('Y',$_SERVER['REQUEST_TIME']).'-'.$moon.'-27' || $showOfflineFlag){
    $method = 2;
    include("common/billcommon_r.php");
}
include("common/billcommon_r_ext.php");
//-------------------------------------------------------
$r=array();
$status=array();
$where="where fid=$memberID and orders<>0";
$sDate = $_REQUEST['btime'] ? $_REQUEST['btime']:date('Y-1-1');
$eDate = $_REQUEST['etime'] ? $_REQUEST['etime']:date('Y-m-d');
$where.=" and etime>='".$sDate." 00:00:00'";
$where.=" and etime<='".$eDate." 23:59:59'";
if(isset($_REQUEST['status'])){
    $status=$_REQUEST['status'];
    $where.=" and status in (".implode(",",$status).")";
}
if($_GET['fid']){
    $fid = $_GET['fid']+0;
    $where .= "and aid=$fid ";
}
$pageSize = $_REQUEST['pageSize'] ? $_REQUEST['pageSize']:15;
$currentPage = $_REQUEST['currentPage'] ? $_REQUEST['currentPage']:1;
$start = ($currentPage-1) * $pageSize;
$limit = " limit $start,$pageSize";
$str="select id,aid,fid,btime,etime,status from uu_bill $where order by id desc $limit";
$GLOBALS['le']->query($str);
while($row=$GLOBALS['le']->fetch_assoc()){
    $r[]=$row;
}

$str="select count(*) as num from uu_bill $where";
$GLOBALS['le']->query($str);
$GLOBALS['le']->fetch_assoc();
$count=$GLOBALS['le']->f("num");

$h3Title="应付款账单";
$about="pay";

foreach($r as $k => $v){
    if(!$dnames[$v['aid']]){
        $sql = "select dname from pft_member where id={$v['aid']} limit 1";
        $GLOBALS['le']->query($sql);
        $GLOBALS['le']->fetch_assoc();
        $dnames[$v['aid']] = $GLOBALS['le']->f('dname');
    }
}
include("tpl/bill.tpl");
include("common/footer.html");?>